﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

/* Generated  */
namespace EDMXParserV1
{
        [Serializable]
    public class Function
    {
        public Function()
        {
            Parameters = new List<Parameter>();
        }
        public string Name = "";
        public string Aggregate = "";
        public string BuiltIn = "";
        public string NiladicFunction = "";
        public string IsComposable = "";
        public string ParameterTypeSemantics = "";
        public string StoreFunctionName = "";
        public string Schema = "";

        public List<Parameter> Parameters;

        public String ReturnTypeAttribute { get; set; }
        public ReturnType ReturnType { get; set; }

        public static Function New(System.Xml.XmlNode Node)
        {
            Function Function = new Function();

            foreach (XmlAttribute Attribute in Node.Attributes)
            {
                switch (Attribute.Name)
                {
                    case "Name":
                        Function.Name = Attribute.Value;
                        break;
                    case "Aggregate":
                        Function.Aggregate = Attribute.Value;
                        break;
                    case "BuiltIn":
                        Function.BuiltIn = Attribute.Value;
                        break;
                    case "NiladicFunction":
                        Function.NiladicFunction = Attribute.Value;
                        break;
                    case "IsComposable":
                        Function.IsComposable = Attribute.Value;
                        break;
                    case "ParameterTypeSemantics":
                        Function.ParameterTypeSemantics = Attribute.Value;
                        break;
                    case "StoreFunctionName":
                        Function.StoreFunctionName = Attribute.Value;
                        break;
                    case "Schema":
                        Function.Schema = Attribute.Value;
                        break;
                    case "ReturnType":
                        Function.ReturnTypeAttribute = Attribute.Value;
                        break;
                    default:
                        Globals.AttributeSwitchCoder(Attribute);
                        break;
                }

            }

            foreach (XmlNode ChildNode in Node.ChildNodes)
            {
                switch (ChildNode.Name)
                {
                    case "Parameter":
                        Parameter Parameter = Parameter.New(ChildNode);
                        Function.Parameters.Add(Parameter);
                        break;

                    case "ReturnType":
                        ReturnType ReturnType = ReturnType.New( ChildNode);
                        Function.ReturnType = ReturnType;
                        break;
                    default:
                        Globals.NodeSwitchCoder(ChildNode);
                        break;
                }
            }

            return Function;
        }
    }
}
